package patterns.proxy;

/**
 * Created by lenovo on 2016/11/28 0028.
 * 代理类，同样实现Image接口，并持有RealImage的对象
 */
public class ProxyImage implements IImage {
    private RealImage realImage;
    private String fileName;

    public ProxyImage(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public void display() {
        if (realImage == null) {
            realImage = new RealImage(fileName);
        }
        realImage.display();
    }
}
